package com.xiongwei.memento;

/**
 * @author XiongWei
 * @date 2024/2/19
 */
public class Client {

    public static void main(String[] args) {

        GameRole gameRole = new GameRole();
        gameRole.setAttack(100);
        gameRole.setDefense(100);

        System.out.println("开始战斗！");
        gameRole.display();

        //保存当前状态
        Caretaker caretaker = new Caretaker();
        caretaker.setMemento(gameRole.createMemento());

        System.out.println("受伤了！");
        gameRole.setAttack(50);
        gameRole.setAttack(50);
        gameRole.display();

        System.out.println("恢复存档");
        gameRole.recoverFromMemento(caretaker.getMemento());
        System.out.println("原地复活！");
        gameRole.display();
    }
}
